<template>
  <div class="public_main">
    <div class="crumbs">
      <el-breadcrumb separator="/">
        <el-breadcrumb-item>{{$t('newcrumbs.crumbsOne')}}</el-breadcrumb-item>
        <el-breadcrumb-item>{{$t('newcrumbs.crumbsTen')}}</el-breadcrumb-item>
        <el-breadcrumb-item>{{$t('finance.crumbsThr')}}</el-breadcrumb-item>
      </el-breadcrumb>
    </div>

    <!-- -------------搜索查询栏------------------------ -->
    <search 
			:searchData="searchData" 
			@search="search" 
			@putExcel="putExcel" 
			:searchRight="true"
			:outputRight="$store.state.common.permiss.putloglist.includes('export')"
    ></search>
    <!-- -------------表单显示栏------------------------ -->
    <!-- <div class="table" v-if="$store.state.common.permiss.includes('RIGHT_ACCOUNT_LENDING_LIST')"> -->
    <div class="table">
      <template>
        <el-table :data="tableData" stripe size="small" v-loading="loadFlag">
          <el-table-column align="center" prop="id" :label="$t('finance.putId')"></el-table-column>
          <el-table-column align="center" prop="orderId" :label="$t('public.orderId')"></el-table-column>
          <el-table-column align="center" prop="userId" :label="$t('public.userId')"></el-table-column>
          <el-table-column align="center" prop="transactionId" :label="$t('finance.transactionId')"></el-table-column>
          <el-table-column align="center" prop="userName" :label="$t('public.name')"></el-table-column>
          <el-table-column align="center" prop="loanType" :label="$t('finance.putMoneyType')">
            <template slot-scope="scope">
              <span>{{scope.row.loanType==1?$t('finance.putType.no1'):$t('finance.putType.no2')}}</span>
            </template>
          </el-table-column>
          <el-table-column align="center" prop="phone" :label="$t('public.no18')">
          </el-table-column>
          <el-table-column align="center" prop="amount" :label="$t('finance.amount')">
            <template slot-scope="scope">
              <span v-if="scope.row.amount!==null&&scope.row.amount!==undefined&&scope.row.amount!==''">{{$store.state.common.id_currency}}{{$store.getters.moneySplit(scope.row.amount)}}{{$store.state.common.vi_currency}}</span>
              <span v-else>{{$store.state.common.nullData}}</span>
            </template>
          </el-table-column>
          <el-table-column align="center" prop="applyTime" :label="$t('public.CreateDate')">
          </el-table-column>
          <el-table-column align="center" prop="loanTime" :label="$t('finance.successDate')">
          </el-table-column>
          <el-table-column align="center" prop="thirdChannel" :label="$t('finance.channel')">
          </el-table-column>
          <el-table-column align="center" prop="bankType" :label="$t('public.bankType')">
          </el-table-column>
          <el-table-column align="center" prop="bankName" :label="$t('public.no19')">
          </el-table-column>
          <el-table-column align="center" prop="email" :label="$t('finance.account')">
          </el-table-column>
          <el-table-column align="center" prop="status" :label="$t('finance.status')">
            <template slot-scope="scope">
              <span>{{$t($store.getters.putMoneyLogStatus(scope.row.status))}}</span>
            </template>
          </el-table-column>
          <el-table-column align="center" prop="remark" :label="$t('public.no37')">
          </el-table-column>
        </el-table>
      </template>
    </div>
    <!-- ------------  分页显示栏  ------------------------ -->
    <el-row type="flex" justify="end">
      <div class="pages" >
        <el-pagination
          @current-change="handleCurrentChange"
          :current-page="pagination.current"
          layout="sizes, prev, pager, next, total,->"
          :page-sizes="pagination.pageSizeOptions"
          :page-size="pagination.pageSize"
          @size-change="handleSizeChange"
          :total="pagination.total">
        </el-pagination>
      </div>
    </el-row>
    <div class="foot"></div>

  </div>
</template>
<script>
import getPayChannel from 'src/mixins/getPayChannel.js';//获取下拉通道
import putExcel from 'src/mixins/putExcel.js';//导出excel
export default {
  name: 'putLogList',
  mixins:[getPayChannel,putExcel],
  data () {
    const searchData=[
      {
        type: 'input',
        label: 'public.orderNo',
        attr: 'orderNo',
        value: ''
      },
      {
        type: 'input',
        label: 'public.orderId',
        attr: 'orderId',
        value: ''
      },
      {
        type: 'input',
        label: 'public.name',
        attr: 'userName',
        value: ''
      },{
        type: 'input',
        label: 'public.userTel',
        attr: 'phone',
        value: ''
      }, {
        type: 'rangePicker',
        label: 'public.CreateDate',
        attr: 'applyTime',
        value: [],
      },
      {
        type: 'rangePicker',
        label: 'finance.createTime',
        attr: 'createTime',
        value: [],
      },
      {
        type: 'rangePicker',
        label: 'finance.successTime',
        attr: 'loanTime',
        value: [],
      },{
        type: 'select',
        label: 'public.no22',
        attr: 'status',
        option: this.$store.state.options.putMoneyLog_select,
        value: '',
        langFlag: true,
      },{
        type: 'select',
        attr: 'thirdChannel',
        label: 'finance.channel',
        option: [],
        value: '',
        langFlag: false,
      }]
    return {
      flag: true,
      loadFlag: true,
      pagination: {
        pageSize: global.config.pageSize,
        pageSizeOptions: global.config.pageSizeOptions,
        current: 1,
        total: 0,
      },
      searchData:searchData,
      formInline: {},// 用户查询信息数据对应字段
      tableData: [],// 用户信息数据模拟
      putExcelUrl:this.$action.finance_loanexport
    }
  },
  methods: {
    handleSizeChange (val) {// 每页条数变化时操作
      this.pagination.pageSize = val;
      this.getTableData();
    },
    handleCurrentChange (val) { // 分页按钮点击操作
      this.pagination.current = val;
      this.getTableData();
    },
    search(search) { // 搜索
      this.formInline = {
        transactionId: search.transactionId,
        orderNo:search.orderNo,
        orderId: search.orderId,
        userName:search.userName,
        phone: search.phone,
        thirdChannel: search.thirdChannel,
        applyTimeBegin: search.applyTime?search.applyTime[0]:'',
        applyTimeEnd: search.applyTime?search.applyTime[1]:'',
        createTimeBegin: search.createTime?search.createTime[0]:'',
        createTimeEnd: search.createTime?search.createTime[1]:'',
        loanTimeBegin: search.loanTime?search.loanTime[0]:'',
        loanTimeEnd: search.loanTime?search.loanTime[1]:'',
        status: search.status,
        thirdChannel:search.thirdChannel
      };
      if (this.flag) {
        this.pagination.currentPage = 1;
        this.flag = false;
        this.getTableData();
      }
      
    },
    getTableData () { // 放款列表获取
      this.loadFlag = true;
      let option = {
        pageNum:this.pagination.current,
        pageSize:this.pagination.pageSize,
        param: {
          ...this.formInline
        }       
      }
      this.$axios.post(this.$action.finance_loanlist, option).then(res => {
        this.flag = true;
        if (res.code == 200) {
          this.tableData = res.data.list;
          this.pagination.total = res.data.total;
        }else{
          this.$globalMsg.error(res.data.message)
        }
        this.loadFlag = false;
      })
    },
    // putExcel () { // excel下载
    //   if (this.flag) {
    //     this.flag = false;
    //     let option = {
    //       pageNum:this.currentPage,
    //       pageSize:this.pageSize,
    //       param: {
    //         partnerId:sessionStorage.partnerId,
    //         ...this.formInline
    //       }       
    //     }
    //     this.$axios.post(this.$action.finance_loanexport, option).then(res => {
    //       this.flag = true;
    //       if (res.code == 200) {
    //         let title = res.data.titles;
    //         let fields = res.data.fields;
    //         let data = res.data.data;
    //         let filename=res.data.fileName;
    //         this.$export2Excel(title,fields,data,filename);
    //       }
    //     })
    //   }
    // }
  },
  mounted () {
    this.getPayChannel().then(arr=>{
      this.searchData[8].option=arr;
    })
    this.getTableData();
  }
}
</script>
<style scoped lang="scss"></style>
